package cn.htsyb.synergy.orm.jpa.model.param;

import cn.htsyb.synergy.orm.constant.ValidStatus;
import cn.htsyb.synergy.orm.jpa.criterion.ExpressBuilder;
import cn.htsyb.synergy.orm.jpa.criterion.QueryExpress;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import org.springframework.util.CollectionUtils;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
/**
 *
 * @author lakeside hubin_yuan.410@hotmail.com
 * @version V1.0.0
 * @date 2022/5/11
 * @since 1.0
 */
@Data
@Schema(description = "实体(简化)请求参数抽象类")
public abstract class AbsIdStatusParam implements Serializable {

    @Schema(name = "id", description = "逻辑编号")
    protected List<String> id;

    @Schema(name = "validStatus", description = "有效类型")
    protected List<ValidStatus> validStatus = new ArrayList<ValidStatus>() {{
        this.add(ValidStatus.enabled);
    }};

    protected List<QueryExpress> searchCriterion() {
        return ExpressBuilder.instance()
                .addExpressOfInOrEq(!CollectionUtils.isEmpty(id), "id", id)
                .addExpressOfInOrEq(!CollectionUtils.isEmpty(validStatus), "validStatus", validStatus)
                .build();
    }

    protected List<QueryExpress> filterCriterion() {
        return new ArrayList<>();
    }

}
